Python Library Objects
From version 7.2, Real-Time Designer has new Python functions enabling you to execute Python code or methods from a file.
To see how to use these functions, see Using Python Functions.
The functions are exposed under Project > References > Library References > Direct.Scripting > Execute Python Function.
To use the Execute Python Code from File function, create an instance of Python Parameters for Code. You can enter the details in the following parameters during initialization or you can invoke a function to assign values to the parameters.
To use the Execute Python Method from File function, create an instance of Python Parameters for Method. You can enter the details in the following parameters during initialization or you can invoke a function to assign values to the parameters.
These functions can accept any number of parameters that can be referenced via a list of parameters. Currently String (text, string, str), Integer (number, integer, int), Boolean, and Decimal parameter types are supported.

Executes a block of Python code written in a text file.
NOTE: Assign values to the parameters (Input Parameter Values, Input Parameter Names, and Parameter Types) either in Python code or in Real-Time Designer. During execution, values present in Python code overrides the values present in Real-Time Designer.
Prerequisites
Before you execute your Python code, you must make sure:
Python is installed on your system.
The Python code is indented properly.
IronPython is installed on your system if you have use Import statements in your code.
Parameter | Input | Description |
---|---|---|
File Path |
Text |
Location and name of the text file which contains the Python code to be executed. |
Input Parameter Values |
List of Text |
Values of the parameters passed in the code |
Module Paths | List of Text | Location of the third-party library, if a third-party library was used in the Python code. |
Names of Input Variables |
List of Text |
Names of the variables passed in the Python code. |
Output Variable |
Text |
Variable used to store the output value after code execution. |
Param Types |
List of Text |
Types of parameters passed in the code. |
Returns
Returns the Python code execution result as text.
Example
import re; expression = "^The.* Spain$" txt = "The rain in Spain" result = re.search(expression, txt)

Executes a Python method present in a Python class within a block of Python code written in a file.
NOTE: Assign values to the parameters (Input Parameter Values, Input Parameter Names, and Parameter Types) either in Python code or in Real-Time Designer. During execution, values present in Python code overrides the values present in Real-Time Designer.
Prerequisites
Python is installed on your system.
The Python code is indented properly.
The method is defined inside a class.
For a non-static method, a self-parameter is passed. For example, def__init__(self).
IronPython is installed on your system if you have used Import statements in your code.
Parameter | Input | Description |
---|---|---|
Class Name | Text | Class that contains the Python method. |
File Path | Text | Location and name of the file which contains the Python method to be executed. |
Method Name | Text | Python method to be executed. |
Module Paths |
List of Text |
Location of the third-party library, if a third-party library was used in the Python code. |
Param Types |
List of Text |
Types of parameters passed in the method. |
Returns
Returns the method function execution result as a text.
Static Example
class Mathematics: @staticmethod def addNumbers(x, y): return x + y
Non-Static Example
Class PyClass: def somemethod(self, exp, tx, num): expression = exp; txt = tx; number = num; result = re.search(expression, txt); return result;